import 'package:flutter/material.dart';

/// 通用加载视图组件
class LoadingView extends StatelessWidget {
  /// 加载提示文本
  final String? message;

  /// 是否显示文本
  final bool showText;

  const LoadingView({Key? key, this.message, this.showText = false})
    : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          const CircularProgressIndicator(),
          if (showText && (message != null && message!.isNotEmpty)) ...[
            const SizedBox(height: 16),
            Text(
              message!,
              textAlign: TextAlign.center,
              style: Theme.of(context).textTheme.bodyMedium,
            ),
          ],
        ],
      ),
    );
  }
}
